local TS = require(game:GetService("ReplicatedStorage"):WaitForChild("rbxts_include"):WaitForChild("RuntimeLib"))
local Roact = TS.import(script, game:GetService("ReplicatedStorage"), "rbxts_include", "node_modules", "@rbxts", "roact", "src", "ts")
local RoactScript =  game:GetService("ReplicatedStorage"):WaitForChild('rbxts_include'):WaitForChild('node_modules'):WaitForChild('@rbxts'):WaitForChild('roact'):WaitForChild('src'):WaitForChild('ts')

local createElement	= require(RoactScript.Parent.createElement)

local Change = require(RoactScript.Parent.PropMarkers.Change)
local Event = require(RoactScript.Parent.PropMarkers.Event)
local Ref = require(RoactScript.Parent.PropMarkers.Ref)

local Symbol = require(RoactScript.Parent.Symbol)
local Type = require(RoactScript.Parent.Type)
local HOST_COMPONENT_NAME_MAPPING = {
	billboardgui = "BillboardGui",
	camera = "Camera",
	canvasgroup = "CanvasGroup",
	frame = "Frame",
	imagebutton = "ImageButton",
	imagelabel = "ImageLabel",
	screengui = "ScreenGui",
	scrollingframe = "ScrollingFrame",
	surfacegui = "SurfaceGui",
	textbox = "TextBox",
	textbutton = "TextButton",
	textlabel = "TextLabel",
	uiaspectratioconstraint = "UIAspectRatioConstraint",
	uicorner = "UICorner",
	uigradient = "UIGradient",
	uigridlayout = "UIGridLayout",
	uilistlayout = "UIListLayout",
	uipadding = "UIPadding",
	uipagelayout = "UIPageLayout",
	uiscale = "UIScale",
	uisizeconstraint = "UISizeConstraint",
	uistroke = "UIStroke",
	uitablelayout = "UITableLayout",
	uitextsizeconstraint = "UITextSizeConstraint",
	viewportframe = "ViewportFrame",
}
function endCss(props)
	local css=props.css
			if css~=nil then
				css.endCss();
			end			
	props.css = nil
end
Roact.jsx=function(component, props, ...)
	local children = nil
	local childrenArraySize = 0
	if props ~=nil then
		endCss(props)
	end
	local function addChild(key, child)
		if children == nil then
			children = {}
		end
		if key then
			child.props.Key = nil
			
			children[key] = child
		else
			childrenArraySize += 1
			children[childrenArraySize] = child
		end
	end

	for i = 1, select("#", ...) do
		local child = select(i, ...)
		if type(child) == "table" then
			if Type.of(child) == Type.Element then
				addChild(child.props.Key, child)
			else
				for key, value in child do
					if type(key) == "number" then
						addChild(nil, value)
					else
						addChild(key, value)
					end
				end
			end
		end
	end

	if component == Roact.Fragment then
		return Roact.createFragment(children)
	end

	component = HOST_COMPONENT_NAME_MAPPING[component] or component

	if props ~= nil and type(component) == "string" then
		if props.Change ~= nil then
			for key, value in props.Change do
				props[Change[key]] = value
			end
			props.Change = nil
		end

		if props.Event ~= nil then
			for key, value in props.Event do
				props[Event[key]] = value
			end
			props.Event = nil
		end

		if props.Ref ~= nil then
			props[Ref] = props.Ref
			props.Ref = nil
		end
	end

	return Roact.createElement(component, props, children)
end
local RoactCss={
    init=function()

    end
}
return RoactCss